package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.mapper.EmployeeMapper;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/***
 * 员工业务实现类
 */
@Service
@Transactional
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private EmployeeMapper mapper;
    @Override
    public void addEmployee(EmployeeBean employee) {
        mapper.addEmployee(employee);
    }

    @Override
    public void delEmployee(int id) {
        mapper.delEmployee(id,"离职");
    }

    @Override
    public void updateEmployee(int id, String phone, int money) {
             mapper.updateEmployee(id, phone, money);
    }

    @Override
    public EmployeeBean findEmployee(int id) {

        return mapper.findEmployee(id);
    }

    @Override
    public EmployeeBean findById(int empId) {
        return mapper.findById(empId);
    }

    @Override
    public PageInfo<EmployeeBean> findByItem(int page, String name, String specialty, String statues, String collations) {
        PageHelper.startPage(page,2);
        PageInfo info = PageInfo.of(mapper.findByItem(name,specialty,statues,collations));
        return info;
    }

    @Override
    public List<EmployeeBean> findNoProject(int id, String name, String skill) {

        return mapper.findByItems(id,name,skill,"离职");
    }
}
